#include "../NewSyndrome-module.h"
#define PASTING_VERSION "0.4.2"
#include <time.h>

#ifdef WIN32
#include <winsock.h>

#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <sys/time.h>
typedef struct sockaddr_in SOCKADDR_IN;
#endif

enum
{ UNKNOW, C_SOURCE, CPP_SOURCE, PASCAL_SOURCE, PHP_SOURCE, BASIC_SOURCE, TXT,
    JAVA_SOURCE };


typedef struct _dcclist dcclist;
struct _dcclist
{
  int sock;
  int port;
  char ip[16];
  unsigned int len;
  unsigned int current_len;
  unsigned int create_time;
  char filename[27];
  char *nick;
  byte type;
  FILE *dfile;
  dcclist *next;
  dcclist *prev;
};


typedef struct pasting_conf_ pasting_conf;
struct pasting_conf_
{
  char *url_base;
  char *path_base;
  unsigned int len_url;
  unsigned int len_path;
  unsigned int socket_max;
  unsigned int taille_max;
  unsigned int nb_socket;
  unsigned int fail_delay;
  unsigned int abort_delay;
  byte dcc_actif;
};


extern dcclist *dcc;
extern pasting_conf pconf;

void conf_it (void);
int data_in_wait (int sock);
int reception_tcp (dcclist * dc);
int connexion_tcp (char *serv, int port);
void int_to_ip (unsigned int i, char *str);
dcclist *get_dcc_by_socket (dcclist * tete, int sok);
dcclist *get_dcc_by_port (dcclist * tete, int port);
dcclist *rm_dcc (dcclist * tete, dcclist * one);
dcclist *add_dcc (dcclist * tete, msg * i);
int coloration_process (char *fin, char *fout, char *fcolor);
